package com.library.service.impl;



import com.library.common.core.domain.BaseEntity;
import com.library.common.core.text.Convert;
import com.library.domain.BoMembershipGrade;
import com.library.mapper.BoMembershipGradeMapper;
import com.library.service.IBoMembershipGradeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 会员等级 服务层实现
 *
 * @author null
 * @date 2020-04-23
 * @blame Android Team
 */
@Service
public class BoMembershipGradeServiceImpl implements IBoMembershipGradeService {
    @Resource
    private BoMembershipGradeMapper boMembershipGradeMapper;

    /**
     * 查询会员等级信息
     *
     * @param id 会员等级ID
     * @return 会员等级信息
     */
    @Override
    public BoMembershipGrade selectBoMembershipGradeById(Long id) {
        return boMembershipGradeMapper.selectBoMembershipGradeById(id);
    }

    /**
     * 查询会员等级列表
     *
     * @param boMembershipGrade 会员等级信息
     * @return 会员等级集合
     */
    @Override
    public List<BoMembershipGrade> selectBoMembershipGradeList(BoMembershipGrade boMembershipGrade) {
        return boMembershipGradeMapper.selectBoMembershipGradeList(boMembershipGrade);
    }

    /**
     * 新增会员等级
     *
     * @param boMembershipGrade 会员等级信息
     * @return 结果
     */
    @Override
    public int insertBoMembershipGrade(BoMembershipGrade boMembershipGrade) {
        return boMembershipGradeMapper.insertBoMembershipGrade(boMembershipGrade);
    }

    /**
     * 修改会员等级
     *
     * @param boMembershipGrade 会员等级信息
     * @return 结果
     */
    @Override
    public int updateBoMembershipGrade(BoMembershipGrade boMembershipGrade) {
        return boMembershipGradeMapper.updateBoMembershipGrade(boMembershipGrade);
    }

    /**
     * 删除会员等级对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteBoMembershipGradeByIds(Long[] ids) {
        for (Long id : ids) {
            BoMembershipGrade membershipGrade = boMembershipGradeMapper.selectBoMembershipGradeById(id);
            membershipGrade.setIsDelete(BaseEntity.DELETE);
            boMembershipGradeMapper.updateBoMembershipGrade(membershipGrade);
        }
        return BaseEntity.DELETE;
    }

}
